package com.chen.webservice.exception;

import com.chen.base.http.ResponseCode;

/**
 * <p>
 *   错误字段定义
 * </p>
 *
 * @author mingbowang
 * @date 2022/6/2
 */
public enum ErrorCode implements ResponseCode {



    HTTP_STATE_404(HttpStatus.HTTP_STATUS_404, "请求的资源不存在"),

    INNER(HttpStatus.HTTP_STATUS_500, "服务器内部异常"),
    GEN_RESP(HttpStatus.HTTP_STATUS_501, "持久层层代码生成异常"),
    GEN_SERVICE(HttpStatus.HTTP_STATUS_502, "业务层代码生成异常"),
    GEN_CONTROL(HttpStatus.HTTP_STATUS_503, "控制层代码生成异常"),

    DB_QUERY(HttpStatus.HTTP_STATUS_504, "数据库查询记录异常"),
    DB_UPDATE(HttpStatus.HTTP_STATUS_505, "数据库更新记录异常"),
    DB_INSERT(HttpStatus.HTTP_STATUS_506, "数据库插入记录异常"),
    DB_DELETE(HttpStatus.HTTP_STATUS_507, "数据库删除记录异常"),

    PARAM_NULL(600, "参数为空"),
    PARAM_TYPE(601, "参数类型非法"),
    PARAM_TYPE_ALL(601, "参数类型非法:{}"),
    PARAM_LONG(602, "参数超长"),
    PARAM_MISSING(603, "参数缺失"),
    PARAM_MISSING_ALL(603, "参数缺失:{}"),
    REQUEST_METHOD(604, "请求方式错误"),
    PARAM_CHECK_FAILURE(605, "参数校验失败"),
    PARAM_CHECK_FAILURE_ALL(605, "参数校验失败:{}"),
    IMPORT_CHECK_FAILURE(606, "导入数据校验失败"),
    INVALID_SORT_FIELD(607, "排序字段不合法"),

    REDIS_SERVER_CONNECT(700, "Redis服务器连接异常"),
    DB_SERVER_CONNECT(701, "数据库连接异常"),

    CACHE_WRITE(800, "缓存写入异常"),

    CACHE_READ(801, "缓存读取异常"),
    
    HQ_CLUSTER(802, "读取spd和hbase文件失败"),
    
    SESSION_ERROR(HttpStatus.HTTP_STATUS_401, "会话数据失效，请重新登录"),
    BUSINESS_ERROR_CUST(10000, "{}"),
    BUSINESS_ERROR(10000, "业务异常"),
    NOT_UPLOAD_TOKEN(401, "用户不存在或者已失效，请重新登入"),

    NOT_NO_ACCESS(401, "用户未授权"),
    NOT_NO_CERTIFICATION(401, "用户未认证"),
    LOGIN_ERROR(402, "登入失败"),

    USERNAME_HAS_EXIST(20000, "账号已存在"),
    TELEPHONE_HAS_EXIST(20001, "手机号已注册"),
    USER_NOT_EXIST(20002, "用户不存在"),
    OLD_PASSWORD_NOT_RIGHT(20003, "旧密码不正确"),
    CANNOT_FOUND_REGISTER_USER(20004, "该手机号无法找到注册用户"),
    CAPTCHA_CODE_NOT_RIGHT(20005, "验证码不正确"),
    TELEPHONE_NOT_REGISTER(20006, "该手机号未注册，短信发送失败"),
    SEND_CAPTCHA_EXCEED_TIMES(20007, "您的手机号验证码发送频繁，超过了今日的次数，请明天再试"),
    EMAIL_HAS_EXIST(20008, "邮箱已被注册"),
    TOKEN_CANNOT_EMPTY(20009, "token不允许为空"),
    CREATE_USER_FILED(20010, "创建用户失败"),
    UPDATE_PASSWORD_ERROR(20011, "修改密码失败"),
//    FAILED_GET_USER_INFO(401, "用户不存在或者已失效，请重新登入"),

    ROLE_NOT_EXIST(30000, "角色不存在"),
    ROLE_NAME_HAS_EXIST(30001, "角色名称已存在"),
    ADMIN_ROLE_CANNOT_UPDATE(30002, "超级管理员不允许编辑"),
    ADMIN_ROLE_CANNOT_DELETE(30003, "超级管理员不允许删除"),
    PASSWORD_PATTERN_ERROR(30004, "密码规则不正确，请输入6位以上含大写字母、小写字母、数字、特殊字符（@$!%#*?&）"),


    CONTENT_ID_CANNOT_BE_NULL(600, "项目id不允许为空"),
    CONTENT_DO_NOT_EXIST(40002, "项目信息不存在"),
    CONTENT_BASIC_DO_NOT_EXIST(40003, "请先填写基础信息"),
    UPLOAD_FAILED(40004, "导入失败"),
    PROJECT_NAME_CANNOT_BE_EMPTY(600, "项目名称不允许为空"),
    CONTENT_NAME_HAS_EXIST(600, "项目名称已存在"),
    UPLOAD_FILE_NOT_EXIST(600, "上传文件不存在"),
    PLEASE_CHOOSE_UPLOAD_OR_MANUAL_METHOD(600, "请选择手动上传文件或者编辑链接方式"),
    PLEASE_EDIT_URL(600, "请输入片花或样点地址"),
    PLEASE_UPLOAD_PICTURE(600, "请上传海报和剧照图片"),
    CONTENT_BASIC_NOT_EXIST(40005, "项目基础不存在"),
    CONTENT_SUPPLY_INFO_NOT_EXIST(40006, "项目补充信息不存在"),
    AUTHORIZATION_PERIOD_FORMAT_ERROR(40007, "授权年限格式有误"),
    EXPORT_PARAM_NOT_EXIST(40008, "模板参输为空,不允许设置模板"),
    GET_MODEL_PRESIGNED_URL_ERROR(40009, "获取模板下载链接错误"),
    DOWNLOAD_LOG_ERROR(40010, "下载中心下载发生异常"),
    EXPORT_PARAM_BE_EMPTY(40011, "请选择导出字段"),
    DOWNLOAD_LOG_DO_NOT_EXIST(40012, "下载中心数据不存在"),
    PLATFORM_HAS_EXIST(600, "平台已存在"),
    PLATFORM_NOT_EXIST(600, "平台不存在"),
    ;

    private Integer code;
    private String message;

    ErrorCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    @Override
    public int getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "ErrorCode {" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
